const ParentUrl = window.location.protocol+"//"+window.location.host;


//获取cookie数据
function getCookie(cookieName) {
    const strCookie = document.cookie
    const cookieList = strCookie.split(';')
    for (let i = 0; i < cookieList.length; i++) {
        const arr = cookieList[i].split('=')
        if (cookieName === arr[0].trim()) {
            return arr[1]
        }
    }
    return ''
}
//删除cookie数据
function deleteCookie(name) {
    this.setCookie(name, "", { expireDays: -1 }); //将过期时间设置为过去来删除一个cookie
}
//获取url值
function getParam(key) {
    var url = window.location.href;
    var params = url.split('?')[1];
    if (params===undefined) return null;//地址无参
    console.log(params);
    var param = params.split('&');
    for(var i = 0; i < param.length; ++i) {
        var paramKeys = param[i].split('=');
        var paramKey = paramKeys[0];
        if(key===paramKey) {
            var value = '';
            for(var j = 1; j < paramKeys.length; ++j) {
                if(paramKeys[j]==='') value+='=';
                else value+=paramKeys[j];
            }
            return value;
        }
    }
    return;
}


const App = {
    mounted() {
    },
    methods: {
        handleClick(tab, event) {
            console.log(tab.index)
            switch (tab.index) {
                case 0: {
                    break;
                }
                case 1: {
                    console.log("aa")
                    axios({
                        method: "get",
                        headers: {
                            'token': getCookie('token')
                        },
                        url: ParentUrl+"/backstage/video"
                    }).then(resp=>{
                        console.log(resp.data)
                    }).catch(resp=>{
                        this.$message({
                            message: '查询失败！',
                            type: 'warning'
                        });
                    });
                    break;
                }
            };
            console.log("bb")
        }
    },
    data() {
        return {
            id: '0001',
            tableData: [
                {
                    time: '2021-1-1',
                    username: '莫',
                    title: '关于XXX的热点讨论'
                }
            ]
        };
    }
}
const app = Vue.createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(ElementPlus);
app.mount("#app");